﻿namespace K9Nano.Settings;

/// <summary>
/// This interface is used to get/set settings from/to a data source (database).
/// </summary>
public interface ISettingStore
{
    /// <summary>
    /// Gets a setting or null.
    /// </summary>
    /// <param name="userId">UserId or null</param>
    /// <param name="name">Name of the setting</param>
    /// <param name="cancellation"></param>
    /// <returns>Setting object</returns>
    Task<SettingInfo?> GetSettingOrNullAsync(long? userId, string name, CancellationToken cancellation = default);

    /// <summary>
    /// Deletes a setting.
    /// </summary>
    /// <param name="setting">Setting to be deleted</param>
    /// <param name="cancellation"></param>
    Task DeleteAsync(SettingInfo setting, CancellationToken cancellation = default);

    /// <summary>
    /// Update a setting.
    /// </summary>
    /// <param name="setting">Setting to add</param>
    /// <param name="cancellation"></param>
    Task CreateOrUpdateAsync(SettingInfo setting, CancellationToken cancellation = default);

    /// <summary>
    /// Gets a list of setting.
    /// </summary>
    /// <param name="userId">UserId or null</param>
    /// <param name="cancellation"></param>
    /// <returns>List of settings</returns>
    Task<IReadOnlyList<SettingInfo>> GetAllListAsync(long? userId, CancellationToken cancellation = default);
}
